const Router = require("koa-router")
const router = new Router();
const MembersModel = require("../../models/members")
router.post("/api/next",async ctx=>{
    var {id} = ctx.request.body;
    var data = await MembersModel.find({});
    var index = data.findIndex(item=>item._id == id);
    // console.log(index);
    if(index == -1){
        ctx.body ={
            code:200,
            msg:"输入的参数不合法",
            request:"POST /api/next"
        }
    }else{
        var obj = data[index+1]
        ctx.body ={
            code:200,
            result:obj,
            msg:"下一条数据"
        }
    }
})
module.exports = router;